import os
from typing import List
from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    """应用配置"""
    model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")

    # OpenAI 配置
    openai_api_key: str = ""
    openai_base_url: str = "https://api.openai.com/v1"

    # 阿里云百炼平台配置
    dashscope_api_key: str = ""
    qwen_model_name: str = "qwen-max"

    # 向量数据库配置
    chroma_persist_dir: str = "./data/chroma_db"
    embedding_model: str = "text-embedding-v3"

    # PaddleOCR 模型路径
    paddleocr_vl_model_dir: str = ""
    layout_detection_model_dir: str = ""

    # 文件上传配置
    upload_dir: str = "./uploads"
    max_upload_size: int = 50  # MB

    # 服务器配置
    host: str = "localhost"
    port: int = 8000
    debug: bool = True

    # CORS 配置
    allowed_origins: List[str] = ["http://localhost:5173", "http://localhost:3000"]
    
    # 日志配置
    log_level: str = "INFO"
    log_file: str = "logs/app.log"

    # 模型配置
    default_model: str = "gpt-4o"
    max_tokens: int = 2048
    temperature: float = 0.7

# 创建全局配置实例
settings = Settings() 